package rabbitMqLearn.spring_boot.work;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import rabbitMqLearn.spring_boot.confg.SpringConfig;

@RestController
@RequestMapping("work")
public class WorkQueueClient {

    //使用这个类来发送消息给队列
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("w1")
    public String w1(@RequestParam("msg") String msg) {
        System.out.println("w1: " + msg);
        rabbitTemplate.convertAndSend("", SpringConfig.WORK_QUEUE, msg);
        return "success";
    }
}
